package com.artifact.mit.mypoint.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.artifact.mit.mypoint.R;
import com.artifact.mit.mypoint.service.model.MenuItem;

public class MenuAdapter extends ArrayAdapter<MenuItem> {
	public MenuAdapter(Context context) {
		super(context, 0);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(
					R.layout.left_nav_row, null);
		}
		ImageView icon = (ImageView) convertView.findViewById(R.id.row_icon);
		icon.setImageResource(getItem(position).iconRes);
		TextView title = (TextView) convertView.findViewById(R.id.row_title);
		title.setText(getItem(position).tag);
		if (getItem(position).nested) {
			ImageView imageView = (ImageView) convertView
					.findViewById(R.id.next);
			imageView.setVisibility(View.VISIBLE);
		}
		return convertView;
	}
}
